package com.firwood.di;

import org.junit.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;

public class DemoTest_di {
	@Test
	public void test01(){
		//
		String xmlPath = "com/firwood/di/beans.xml";
		ApplicationContext applicationContext = new ClassPathXmlApplicationContext(xmlPath);
		Outer outer = applicationContext.getBean("OuterId",Outer.class);
		outer.print();
	}
	
	@Test
	public void test02(){
		String xmlPath="com/firwood/di/beans.xml";
		ApplicationContext applicationContext = new ClassPathXmlApplicationContext(xmlPath);
		Outer outer = applicationContext.getBean("OuterId",Outer.class);
		outer.print();
	}
	
	@Test
	public void test03(){
		String xmlPath="com/firwood/di/beans.xml";
		BeanFactory bf = new XmlBeanFactory(new ClassPathResource(xmlPath));
		Outer outer = bf.getBean("OuterId", Outer.class);
		System.out.println(outer);
		Outer outer2 = bf.getBean("OuterId",Outer.class);
		System.out.println(outer2);
		
		outer.print();
		
		System.out.println(outer == outer2);
	}
}
